﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TGBTech.Core.Models.DanhMuc;

namespace TGBTech.Core.Models.Services
{
    public class TaiKhoanSoService
    {
        public TaiKhoanSo getTaiKhoanSoByName(String name)
        {
            TaiKhoanSo taikhoanso = null;
            //init context
            using (var db = new TGB.Core.Infrastructure.TGBTechDb())
            { 
                //search query
                var searchQuery = from e in db.TaiKhoanSo
                                  where e.Name.Contains(name)
                                  select e;
                var results = searchQuery.ToList();
                if (results != null || results.Count > 0)
                {
                    taikhoanso = results.FirstOrDefault();
                }
            }
            return taikhoanso;
        }
    }
}
